home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: February 01, 2001
- //
- // Description:
- // This is a script to perfrom the filterCurve command
- // with options for resampling.
- //
- // Input Arguments:
- // int action 0 - just execute the command
- // 1 - show the option box dialog
- // 2 - return the drag command
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- keySetOptionBoxCommon( { "resample",
- "unknown",
- "setOptionVars",
- $forceFactorySettings } );
-
- // Resample kernel types
- //
- // 1: Closest Sample
- // 2: Linear Interpolation
- // 3: Box Filter
- // 4: Triangle Filter
- // 5: Gaussian 2
- // 6: Gaussian 4
- //
- if ($forceFactorySettings ||
- !`optionVar -exists resampleKernel`) {
- optionVar -intValue resampleKernel 5;
- }
-
- // timeStep
- //
- if ($forceFactorySettings || !`optionVar -exists resampleTimeStep`) {
- optionVar -floatValue resampleTimeStep 1.0;
- }
- }
-
- global proc resampleSetup (string $parent, string $selectionConnection, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars ($forceFactorySettings);
-
- setParent $parent;
-
- keySetOptionBoxCommon( { "resample", $selectionConnection, "setup", 0 } );
-
- // Set the correct menu for the resample kernel
- //
- int $kernel = `optionVar -query resampleKernel`;
- if ($kernel < 1 || $kernel > 6) {
- $kernel = 5;
- }
- optionMenuGrp -e -sl $kernel resampleKernelMenuGrp;
-
- // -timeStep
- //
- float $timeStep = `optionVar -query resampleTimeStep`;
- floatFieldGrp -edit -value1 $timeStep resampleTimeStep;
-
- resampleWidgetsEnable ($selectionConnection);
- }
-
-
- global proc resampleCallback( string $parent, int $doIt,
- string $selectionConnection, int $performAction )
- {
- setParent $parent;
-
- keySetOptionBoxCommon( { "resample", $selectionConnection, "callback" } );
-
- // Resample kernel
- //
- int $kernel = `optionMenuGrp -q -sl resampleKernelMenuGrp`;
- optionVar -intValue resampleKernel $kernel;
-
- // -timeStep
- //
- optionVar
- -floatValue
- resampleTimeStep
- `floatFieldGrp -query -value1 resampleTimeStep`;
-
- if( $doIt ) {
- performResample( $performAction, $selectionConnection);
- string $tmpCmd = "performResample ";
- $tmpCmd += "\"" + $performAction + "\", ";
- $tmpCmd += "\"" + $selectionConnection + "\"";
- addToRecentCommandQueue $tmpCmd "Resample";
- }
- }
-
- global proc resampleWidgetsEnable(string $selectionConnection)
- {
- keySetOptionBoxCommon( { "resample", $selectionConnection, "enable" } );
- }
-
- proc string resampleWidgets( string $tabLayout, string $selectionConnection )
- {
- setParent $tabLayout;
-
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- keySetOptionBoxCommon( { "resample", $selectionConnection, "widgets", 1, 0, 1 } );
-
- optionMenuGrp -l "Resample Type" resampleKernelMenuGrp;
- menuItem "Closest Sample";
- menuItem "Linear Interpolation";
- menuItem "Box Filter";
- menuItem "Triangle Filter";
- menuItem "Gaussian 2";
- menuItem "Gaussian 4";
-
- floatFieldGrp -label "Time Step" -precision 2 -value1 1.0 resampleTimeStep;
-
- return $tabForm;
- }
-
- global proc resampleDoSelectionChanged(string $selectionConnection)
- //
- // Description:
- // Since timeRange is irrelevant when there are
- // picked keyframes, collapse the timeRange
- // when there are. (This is hooked in to a SelectionChanged
- // trigger.)
- //
- {
- keySetOptionBoxCommon( { "resample", $selectionConnection, "selectionChanged" } );
- resampleWidgetsEnable ($selectionConnection);
- }
-
-
- proc resampleOptions( string $selectionConnection, int $performAction )
- {
- // Customisation options
- //
- // Name of the command for this option box (think of it as the base class)
- string $commandName = "resample";
- // Title for the option box window
- string $optionBoxTitle = "Resample Curve Options";
- // Title for the apply button
- string $applyTitle = "Resample";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Build the window, with a tab layout
- //
- string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`;
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Make the form invisible while we create the widgets in the window
- //
- formLayout -e -vis false $widgetList[1];
-
- // Attach each tab
- //
- resampleWidgets $widgetList[2] $selectionConnection;
-
- // Attach the standard buttons
- //
- string $buttonList[] = `addStandardButtons $commandName $applyTitle
- $widgetList[1] $widgetList[2] "noOptions"`;
-
- // attach commands to the standard buttons
- //
- // Save
- //
- button -e -c ($callback + " " + $widgetList[0] + " false \"\" " + $performAction +
- "; hideOptionBox()") $buttonList[3];
-
- // Close
- //
- button -edit -command hideOptionBox $buttonList[2];
-
- // Reset
- //
- button -edit -command ($setup + " " + $widgetList[0] + " " + $selectionConnection + " true") $buttonList[1];
-
- // Do It
- //
- button -edit -command ($callback + " " + $widgetList[0] + " true \"" +
- $selectionConnection + "\"" + $performAction) $buttonList[0];
-
- // Make the form layout visible so we can see what we built, and
- // reset the template
- //
- formLayout -e -vis true $widgetList[1];
- setUITemplate -popTemplate;
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "ResampleCurves" );
-
- // Call the setup "method" to fill in the current settings
- //
- eval (($setup + " " + $widgetList[0] + " " + $selectionConnection + " false"));
- showOptionBox();
- showWindow $widgetList[0];
-
- resampleDoSelectionChanged($selectionConnection);
- scriptJob -protected
- -event "SelectionChanged" ("resampleDoSelectionChanged " + $selectionConnection)
- -parent $widgetList[2];
- }
-
- proc string assembleCmd( string $selectionConnection, string $options )
- {
- string $cmd = "doResampleArgList 1 { " +
- "\"" + `optionVar -q resampleWhichRange` + "\"" +
- ",\"" + `optionVar -q resampleRange` + "\"" +
- ",\"" + `optionVar -q resampleKernel` + "\"" +
- ",\"" + `optionVar -q resampleTimeStep` + "\"" +
- ",\"" + $selectionConnection + "\"" +
- ",\"" + $options + "\"" +
- " };";
-
- return $cmd;
- }
-
- // The action variable means
- // 0 - do the command
- // 1 - show the option box
- // 2 - return the drag command
- // 3 - do the command (bufferCurve version)
- // 4 - show the option box (bufferCurve version)
- // 5 - return the drag command (bufferCurve version)
- //
- global proc string performResample( int $action, string $selectionConnection )
- {
- string $cmd = "";
-
- switch( $action ) {
- case 0:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, "noOptions" );
- eval( $cmd );
- break;
- case 1:
- resampleOptions( $selectionConnection, 0 );
- break;
- case 2:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, "noOptions" );
- break;
- case 3:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, "bufferCurve" );
- eval( $cmd );
- break;
- case 4:
- resampleOptions( $selectionConnection, 3 );
- break;
- case 5:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, "bufferCurve" );
- break;
- }
- return ($cmd);
- }
-